package com.sdk.util;

import java.text.SimpleDateFormat;

public class FormatUtil {
	/**
	 * 格式化容量
	 * 
	 * @param size
	 * @return
	 */
	public static String formateSize(long size) {
		if (size < (1 << 10)) {
			return size + "B";
		} else if (size < (1 << 20)) {
			return (size >> 10) + "KB";
		} else if (size < (1 << 30)) {
			return (size >> 20) + "MB";
		} else if (size < (1 << 40)) {
			return (size >> 30) + "GB";
		} else {
			return (size >> 40) + "TB";
		}
	}

	private final static SimpleDateFormat DATE_FORMATE_TYPE1 = new SimpleDateFormat(
			"yyyy-MM-dd");

	/**
	 * 格式化时间
	 * 
	 * @param time
	 * @return
	 */
	public static String formateTime(long time) {
		return DATE_FORMATE_TYPE1.format(time);
	}
}
